<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="js/mui.min.js"></script>
		<script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<script src="yegou.js"></script>
	</head>

	<body>
		<button onclick="changeVal();"></button>
		<button onclick="updateVal();">更新</button>
		<button onclick="createVal();">新增</button>
	</body>
	<script>
		var network = false;
		var ref = null;
		mui.plusReady(function() {
			if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
				mui.toast("当前网络不给力，无法连接云端数据库~");
			} else {
				network = true;
				ref = new Wilddog("https://sunafei.wilddogio.com");
			}
			createVal();
		});

		function getList() {
			ref.once("value", function(snapshot) {
				var result = snapshot.val();
			});
		}
		function changeVal() {
			alert("a");
			var ref1 = new Wilddog("https://sunafei.wilddogio.com/user/");
			ref1.once("value", function(snapshot) {
				var result = snapshot.val();
				console.log(JSON.stringify(result))
				mui.each(result, function(key, elem) {
					console.log(JSON.stringify(elem))
				});
			});
		}
		function updateVal() {
			var ref2 = new Wilddog("https://sunafei.wilddogio.com/user");
			ref2.update({"name":"奇奇怪怪"});
		}
		function createVal() {
			var ref3 = new Wilddog("https://sunafei.wilddogio.com/user");
			ref3.push({"name":"sunafei"});
		}
	</script>

</html>